<template>
	<view>
		<!-- <view class="cu-bar search bg-white">
			<view class="search-form round">
				<text class="cuIcon-search"></text>
				<input v-model="searchValue" data-name="searchValue" name="searchValue" @focus="onChange" @blur="onSearch"
				 :adjust-position="false" placeholder="请输入小区编号" confirm-type="search"></input>
			</view>
			<view class="action">
				<button class="cu-btn bg-green shadow-blur round" @tap="onSearch">搜索</button>
			</view>
		</view> -->
		<view v-if="unitsNum.length>0">
			<view class="padding">单元信息</view>
			<view class="cu-list menu">
				<view class="cu-item" v-for="(unit, idx) in unitsNum" :key="idx" :label="unit.id">
					<view class="content padding-tb-sm" is-link @click="chooseUnit(unit)">
						<view>
							<text class="cuIcon-clothesfill text-blue margin-right-xs"></text> {{unit.unitName}}</view>
						<view class="text-gray text-sm">
							<text class="cuIcon-infofill margin-right-xs"></text> {{unit.unitCode}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<view v-else>
			<no-data-page></no-data-page>
		</view>
	</view>
</template>

<script>
	import context from '../../lib/java110/Java110Context.js';
	const constant = context.constant;
	import noDataPage from '@/components/no-data-page/no-data-page.vue'
	export default {
		data() {
			return {
				roomDetail:'',
				plotInfo:"",
				unitsNum:"",
				appUserName: '',
				areaCode: '',
				searchValue: '',
				unitName: "",
				unitId:"",
				units: [],
				floorId:'',
				ownUtil:''
			}
		},
		components: {
			noDataPage
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		// onLoad: function(options) {
		// 	context.onLoad(options);
		// 	// this.plotInfo = options.vUnit);
		// 	console.log("楼栋下单元",JSON.parse(options.vUnit))
		// 	this.loadUnit();
		// },
		onLoad: function(options) {
			let _that = this;
			context.onLoad(options);
			_that.roomDetail = JSON.parse(options.vUnit);
			_that.unitsNum = _that.roomDetail.children
			// _that.stepsData = _that.roomDetail.bindSteps;
		},
		methods: {
			onSearch() {
				this.loadUnit();
			},

			// onClick() {
			// 	this.loadUnit();
			// },
			
			chooseUnit: function(_unit) {
				let pages = getCurrentPages();
				let prevPage = pages[pages.length - 2];
				uni.setStorageSync("_selectUnit", _unit);
				prevPage.unitName = _unit.unitName;
				console.log(_unit.unitName,"666666");
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style>

</style>
